package com.wy2cloud.esdemo.service;

import java.io.IOException;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wy2cloud.esdemo.entity.SystemUser;
import com.wy2cloud.esdemo.repository.UserRepository;

import io.searchbox.client.JestResult;
import io.searchbox.core.BulkResult;
import io.searchbox.core.DocumentResult;

@Service
public class UserService {

	@Autowired
	private UserRepository userRepository;
    
	public DocumentResult insertDocument(String indexName,String typeName,SystemUser entity) throws Exception{
		return userRepository.insertDocument(indexName, typeName, entity);
	}
	public BulkResult insertDocument(String indexName,String typeName,List<SystemUser> entities) throws Exception{
        return userRepository.insertDocument(indexName, typeName, entities);
    }
	
	public JestResult createIndex(String indexName) throws Exception{
	    return userRepository.createIndex(indexName);
	}
	public JestResult deleteIndex(String indexName) throws Exception{
	    return userRepository.deleteIndex(indexName);
	}
	
	public JestResult nodesInfo() throws Exception{
		return userRepository.nodesInfo();
	}
	
	public JestResult nodesStats() throws Exception{
		return userRepository.nodesStats();
	}
}
